from dao import db
from sqlalchemy import Column, Integer, String,ForeignKey
from sqlalchemy.orm import relationship

class Portrait(db.Model):
    id = Column(Integer, primary_key = True)
    name = Column(String(128))
    path = Column(String(256))
    type = Column(Integer)
    user_id =  Column(Integer, ForeignKey('user.id'))
    user = relationship('User', backref='portaits')
    
    def __init__(self, name, description, path, type):
        self.name = name
        self.path = path
        self.type = type

    def __repr__(self):
        return '<Portrait %r>' % (self.name)

if __name__ == '__main__':
    # create table
    db.drop_all()
    db.create_all()